package ltd.sshine.bot.config.scan;

import java.util.HashMap;
import java.util.Map;

public class EventHandlerFactory {
//    private static Logger logger = Logger.getLogger(ServletHandlerFactory.class);

    private static final Map<String,Object> classes = new HashMap<>();

    public static void put(Class<?> clazz){
        try {
//            System.out.println("初始化ServletHandler类:"+ clazz.getName());
            Object servlet = clazz.newInstance();
            classes.put(clazz.getName(), servlet);
        } catch (InstantiationException | IllegalAccessException e) {
            System.out.println("初始化事件类:" + clazz.getName() + "失败:" + e.getMessage());
        }
    }

    @SuppressWarnings("unchecked")
    public static <T> T get(String className){
        return (T)classes.get(className);
    }
}
